import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
import _InputBase from "@mui/material/InputBase";
import React, { useState, memo, useEffect } from "react";
import styles from "./index.module.less";
import images from "../../assets";
import classNames from "classnames";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Component = function(props) {
    var placeholder = props.placeholder, maxlength = props.maxlength, _props_type = props.type, type = _props_type === void 0 ? "text" : _props_type, value = props.value, onChange = props.onChange, _props_password = props.password, password = _props_password === void 0 ? false : _props_password, name = props.name, onBlur = props.onBlur, error = props.error;
    var _useState = _sliced_to_array(useState(true), 2), visible = _useState[0], setVisible = _useState[1];
    var _useState1 = _sliced_to_array(useState(password), 2), initpassword = _useState1[0], setInitPassword = _useState1[1];
    useEffect(function() {
        setInitPassword(password);
    }, []);
    return /*#__PURE__*/ _jsxs("div", {
        className: classNames(styles.page, error ? styles.error : ""),
        children: [
            /*#__PURE__*/ _jsx("div", {
                className: styles.code,
                children: /*#__PURE__*/ _jsx(_InputBase, {
                    placeholder: placeholder,
                    className: styles.input,
                    type: initpassword ? "password" : type,
                    value: value,
                    onChange: function(e) {
                        return onChange && onChange(e.target.value);
                    },
                    name: name,
                    onBlur: onBlur
                })
            }),
            type === "safe-password" ? /*#__PURE__*/ _jsx("div", {
                className: styles.send,
                onClick: function() {
                    setVisible(!visible);
                    setInitPassword(!initpassword);
                },
                children: /*#__PURE__*/ _jsx("img", {
                    src: visible ? images.eyeHide : images.eye,
                    className: styles.eye
                })
            }) : value && (value === null || value === void 0 ? void 0 : value.length) > 0 ? /*#__PURE__*/ _jsx("div", {
                className: styles.send,
                onClick: function() {
                    return onChange && onChange("");
                },
                children: /*#__PURE__*/ _jsx("img", {
                    src: require("../../assets/icons/clear.svg"),
                    className: styles.close
                })
            }) : /*#__PURE__*/ _jsx("div", {})
        ]
    });
};
var LinearInput = /*#__PURE__*/ memo(Component);
export default LinearInput;

 //# sourceMappingURL=index.js.map